package com.wj.actionbar2;


import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;


public class MainActivityB extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		ActionBar abar=getActionBar();
		abar.setDisplayHomeAsUpEnabled(true);
	}

	//设置菜单
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		MenuInflater inflater = getMenuInflater();  
		inflater.inflate(R.menu.main, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch(item.getItemId()){
		case android.R.id.home:
			finish();
			return true;
		case R.id.it1:
			Toast.makeText(this, "球", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.it2:
			Toast.makeText(this, "伞", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.it3:
			Toast.makeText(this, "蓝牙", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.it5:
			Toast.makeText(this, "杯子", Toast.LENGTH_SHORT).show();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	
	
	
}
